<?php

namespace library;

//腾讯地图
use GuzzleHttp\Client;

class tencent_map
{

    //逆地址解析
    public function geocoder($lat,$lng)
    {

        $location =$lat.','.$lng;
        $url = "https://apis.map.qq.com/ws/geocoder/v1/?location=" . $location . "&key=" . env('TENCENT_MAP_KEY') . "&get_poi=1";

        $client = new Client();
        $response = $client->get($url);
        $data = json_decode($response->getBody(), true);
        return $data;
    }

    //逆地址解析
    public function geocoder2($lat,$lng)
    {

        $location =$lat.','.$lng;

        //https://restapi.amap.com/v3/geocode/regeo?output=xml&location=116.310003,39.991957&key=<用户的key>&radius=1000&extensions=all
        $url = "https://restapi.amap.com/v3/geocode/regeo?output=json&location=" . $location . "&key=" . env('GAODE_MAP_KEY') . "&radius=1000&extensions=all";
       // $url = "https://apis.map.qq.com/ws/geocoder/v1/?location=" . $location . "&key=" . env('TENCENT_MAP_KEY') . "&get_poi=1";

        $client = new Client();
        $response = $client->get($url);
        $data = json_decode($response->getBody(), true);
        return $data;
    }




}